package com.wao.product.service.mapper;

import com.wao.product.domain.*;
import com.wao.product.service.dto.ProductSkuDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity ProductSku and its DTO ProductSkuDTO.
 */
@Mapper(componentModel = "spring", uses = {ProductMapper.class, })
public interface ProductSkuMapper extends EntityMapper <ProductSkuDTO, ProductSku> {

    @Mapping(source = "product.id", target = "productId")
    @Mapping(source = "product.name", target = "productName")
    ProductSkuDTO toDto(ProductSku productSku); 

    @Mapping(source = "productId", target = "product")
    ProductSku toEntity(ProductSkuDTO productSkuDTO); 
    default ProductSku fromId(Long id) {
        if (id == null) {
            return null;
        }
        ProductSku productSku = new ProductSku();
        productSku.setId(id);
        return productSku;
    }
}
